package ar.com.personalTravellers.generators;

import ar.com.personalTravellers.spring.ApplicationContextSpring;
import com.angel.arquitectura.constants.ArquitecturaDAOsNames;
import com.angel.arquitectura.model.configuration.ConfigurationParameter;
import com.angel.dao.generic.factory.DAOFactory;
import com.angel.dao.generic.interfaces.GenericDAO;
import com.angel.data.generator.interfaces.DataGenerator;

import java.io.Serializable;
import java.util.Collection;

/**
 *
 * @author William
 */
public class ConfigurationParameterDataGenerator implements DataGenerator {
    /**
	 * 
	 */
	private static final long serialVersionUID = -9016187611831969598L;

	@SuppressWarnings("unchecked")
	public Class<? extends DataGenerator>[] getDependecesGenerators() {
        return (Class<? extends DataGenerator>[]) new Class[0];
    }

    public void generateData(Collection<Object> objects, DAOFactory daoFactory) {
        ConfigurationParameter convertionDolarToArgentinianPesos = new ConfigurationParameter();
        convertionDolarToArgentinianPesos.setName("DOLLAR_PESOS");
        convertionDolarToArgentinianPesos.setDescription("Conversion parameter between dollar and argentinian pesos.");
        convertionDolarToArgentinianPesos.setDoubleValue(3.70);
        objects.add(convertionDolarToArgentinianPesos);

        ConfigurationParameter convertionEuroToArgentinianPesos = new ConfigurationParameter();
        convertionEuroToArgentinianPesos.setName("EURO_PESPS");
        convertionEuroToArgentinianPesos.setDescription("Conversion parameter between euro and argentinian pesos.");
        convertionEuroToArgentinianPesos.setDoubleValue(4.55);
        objects.add(convertionEuroToArgentinianPesos);

        ConfigurationParameter allowLogErrorMessages = new ConfigurationParameter();
        allowLogErrorMessages.setName("ALLOW_LOG_ERROR_MESSAGES");
        allowLogErrorMessages.setDescription("Allow application logs error messages.");
        allowLogErrorMessages.setBooleanValue(true);
        objects.add(allowLogErrorMessages);
    }

    public Class<? extends Object> getDataGeneratorClass() {
        return ConfigurationParameter.class;
    }

    @SuppressWarnings("unchecked")
	public GenericDAO<Object, Serializable> getGenericDAO() {
        return (GenericDAO<Object, Serializable>) ApplicationContextSpring.createInstance().prepareApplicationContext().getBean(ArquitecturaDAOsNames.CONFIGURATION_PARAMETER_DAO_NAME);
    }
}